<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-zhGood-edit" th:object="${zhGood}">
            <input id="id" name="id" th:field="*{id}"  type="hidden">

			<div class="form-group" style="display: none">
				<!--				<div class="form-group" >-->
				<label class="col-sm-3 control-label">游戏区服id：</label>
				<div class="col-sm-8">
					<input id="areaId" name="areaId" th:field="*{areaId}" class="form-control" type="text" readonly="readonly"  >
				</div>
			</div>


			<div class="form-group">
				<label class="col-sm-3 control-label">站点：</label>
				<div class="col-sm-8">
					<select id="deptId" name="deptId" class="form-control m-b" th:field="*{deptId}">
						<option th:each="zhDept:${zhDepts}" th:value="${zhDept.deptId}" th:text="${zhDept.name}" th:field="*{deptId}"></option>
					</select>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">游戏名称：</label>
				<div class="col-sm-8">
					<select id="gameId" name="gameId" class="form-control m-b" >
						<option th:each="item:${zhGameInfos}" th:value="${item.id}" th:text="${item.name}" th:field="*{gameId}"></option>
					</select>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">游戏区服：</label>
				<div class="col-sm-8">
					<input id="areaName" th:field="*{gameAreaName}" class="form-control" type="text" readonly="readonly" style="cursor: pointer" onclick="selectGameAreaTree()" >
				</div>
			</div>


			<div class="form-group">
				<label class="col-sm-3 control-label">是否置顶：</label>
				<div class="col-sm-8">
					<select id="ifTop" name="ifTop" class="form-control m-b"  th:field="*{ifTop}">
						<option value="0">否</option>
						<option value="1">是</option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">商品名称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" th:field="*{name}" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">库存：</label>
				<div class="col-sm-8">
					<input id="stock" name="stock" th:field="*{stock}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">卖家用户名：</label>
				<div class="col-sm-8">
					<input id="salerUsername" name="salerUsername" th:field="*{salerUsername}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">价格：</label>
				<div class="col-sm-8">
					<input id="price" name="price" th:field="*{price}" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">删除标志：</label>
				<div class="col-sm-8">
					<input id="delFlag" name="delFlag" th:field="*{delFlag}" class="form-control" type="text">
				</div>
			</div>


			<div class="form-group">
				<label class="col-sm-3 control-label">是否下架：</label>
				<div class="col-sm-8">
					<select id="ifSuspend" name="ifSuspend" class="form-control m-b"  th:field="*{ifSuspend}">
						<option value="0">否</option>
						<option value="1">是</option>
					</select>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" name="remark" class="form-control" th:field="*{remark}"></textarea>
				</div>
			</div>

			<div class="form-group" style="display: none;">
				<label class="col-sm-3 control-label">图片url：</label>
				<div class="col-sm-8">
					<input id="image" name="image" class="form-control img_upload" type="text">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">图片：</label>
				<button type="button" class="layui-btn" id="test1" style="margin-left: 15px;">
					<i class="layui-icon">&#xe67c;</i>上传图片
				</button>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">预览：</label>
				<img id="preview" th:src="*{image}" height="100" width="150" style="cursor: pointer;margin-left: 15px;"/>
			</div>

		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "system/zhGood";
		$("#form-zhGood-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/edit", $('#form-zhGood-edit').serialize());
	        }
	    }

		/*选择游戏区服树*/
		function selectGameAreaTree() {
			var gameId=$('#gameId').val()
			var options = {
				title: '游戏区服选择',
				width: "380",
				url: '/system/zhGameArea/tree?gameId='+gameId,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		function doSubmit(index, layero){
			var body = layer.getChildFrame('body', index);
			$("#areaId").val(body.find('#treeId').val());
			$("#areaName").val(body.find('#treeName').val());
			layer.close(index);
		}
	</script>

	<script type="text/javascript">
		layui.use('upload', function(){
			var preview_img =$('#preview')
			preview_img.on("click",function(e){
				layer.photos({ photos: {"data": [{"src": e.target.src}]} });
			});
			var upload = layui.upload;
			var layer = layui.layer;
			//执行实例

			renderUpload(upload,$('#test1'),$('#preview'),$('#image'))
		});
	</script>
</body>
</html>
